package com.kushuigu;

import com.kushuigu.config.SpringConfig;
import com.kushuigu.dao.BookDao;
import com.kushuigu.service.BookService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import javax.sql.DataSource;

public class AppForAnnotation {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfig.class);
        BookDao bookDao = (BookDao) ctx.getBean("bookDao");
        BookDao bookDao2 = (BookDao) ctx.getBean("bookDao");
        System.out.println(bookDao);
        System.out.println(bookDao2);
        ctx.getBean(BookService.class).save();
        System.out.println(ctx.getBean(DataSource.class));
        ctx.close();
    }
}
